package com.wenhui.schoolyardinfo.square.ui;

import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.qmuiteam.qmui.widget.QMUITopBar;
import com.wenhui.schoolyardinfo.R;
import com.wenhui.schoolyardinfo.base.BaseActivity;
import com.wenhui.schoolyardinfo.callback.RcvOnItemViewClickListener;
import com.wenhui.schoolyardinfo.square.adapter.RecommendAdapter;
import com.wenhui.schoolyardinfo.square.bean.RecommendBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author    : Urasaki
 * e-mail    : 1164688204@qq.com
 * date      : 2019/7/5 9:12
 * introduce : 为你推荐activity
 */

public class RecommendActivity extends BaseActivity implements RcvOnItemViewClickListener {

    private static final String TAG = "RecommendActivity";
    @BindView(R.id.imv_back)
    ImageView imvBack;
    @BindView(R.id.layout_back)
    RelativeLayout layoutBack;
    @BindView(R.id.topbar)
    QMUITopBar topbar;
    @BindView(R.id.mine_recycler_view)
    RecyclerView mineRecyclerView;

    private List<RecommendBean> recommendBeanList;
    private RecommendAdapter recommendAdapter;
    private LinearLayoutManager layoutManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recommend);
        ButterKnife.bind(this);

        initData();
        initViews();
    }

    @Override
    protected void initData() {
        recommendBeanList = new ArrayList<>();
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "素华流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "冉冉流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "素华流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "冉冉流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "素华流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "冉冉流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "冉冉流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "素华流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "似水流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "素华流年", 300, 1000000));
        recommendBeanList.add(new RecommendBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "冉冉流年", 300, 1000000));
    }

    @Override
    protected void initViews() {
        setTopBar(topbar);

        layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(OrientationHelper.VERTICAL);
        mineRecyclerView.setLayoutManager(layoutManager);
        mineRecyclerView.setItemAnimator(new DefaultItemAnimator());

        recommendAdapter = new RecommendAdapter(this);
        mineRecyclerView.setAdapter(recommendAdapter);
        recommendAdapter.setRcvOnItemViewClickListener(this);
        recommendAdapter.clearData();
        recommendAdapter.addAllData(recommendBeanList);
    }

    @Override
    public void onItemClickListener(int position, View view) {
        switch (view.getId()) {
            case R.id.layout_concern_add:
                showToast("layout_concern_add");
                break;
            default:
                break;
        }
    }

    @OnClick(R.id.layout_back)
    public void onViewClicked() {
        finish();
    }
}
